
<ul id="slideshow" class="slider bxslider">
    <?php
    echo '<li>';
    $i = 1;
    $count = sizeof($list_tvshow);
    foreach ($list_tvshow AS $item):
        ?>
        <div class="item">
            <a <?php if ($item['starting'] == 1): ?>data-link="href"<?php endif; ?> href="<?php echo $baseurl; ?>chuong-trinh/<?php echo $item['name_ascii']; ?>.html" data-channel_logo='<?php echo $imgurl . $item['logo']; ?>' data-time='<?php echo $item['schedule']; ?>' data-starting='<?php echo $item['starting']; ?>' data-poster='<?php echo $imgurl . $item['program_logo']; ?>'>
                <div class="border">
                    <div class="image" style="background: url(<?php echo $imgurl . $item['avatar_web']; ?>) no-repeat"></div>
                    <div class="info">
                        <div class="logo" style="background: url(<?php echo $imgurl . $item['logo']; ?>) no-repeat"></div>
                        <div class="schedule <?php
                        if ($item['starting'] == 1) {
                            echo 'playing';
                        }
                        ?>">
                                 <?php
                                 if ($item['starting'] == 1) {
                                     echo '<p><span>Đang tương tác</span></p>';
                                 } else {
                                     echo '<p><span>' . $item['schedule'] . '</span></p>';
                                 }
                                 ?></div>
                    </div>
                </div>
            </a>
            <?php if ($item['follow'] == 1): ?>
                <button data-id="<?php echo $item['id']; ?>" class="btn follow-button btn-unfollow follow-<?php echo $item['id']; ?>"></button>
            <?php else: ?>
                <button data-id="<?php echo $item['id']; ?>" class="btn follow-button btn-follow follow-<?php echo $item['id']; ?>"></button>
            <?php endif; ?>
        </div>
        <?php
        if ($i == 6 && $count == 6) {
            echo '</li>';
            $i = 0;
        } else if ($i == 6) {
            echo '</li><li>';
            $i = 0;
        }
        ?>
        <?php
        $i++;
    endforeach;
    ?>
</ul>
<div class="Wrapp_msslideshow">
    <ul id="sm-slideshow">
        <?php foreach ($list_tvshow as $item): ?>
            <li class="<?php echo $item['starting'] == '1' ? 'Playing' : '' ?>">

                <?php if ($item['follow'] == 1): ?>
                    <button id="sfollow_<?php echo $item['id'] ?>" data-key="slide_<?php echo $item['id'] ?>" data-id="<?php echo $item['id']; ?>" class="btn btn-unfollow"></button>
                <?php else: ?>
                    <button id="sfollow_<?php echo $item['id'] ?>" data-key="slide_<?php echo $item['id'] ?>" data-id="<?php echo $item['id']; ?>" class="btn btn-follow"></button>
                <?php endif; ?>

                <div id='Preload_slide_<?php echo $item["id"] ?>' class='Preload'><div class='Preload_inner'></div></div>
                <div class="image" style="background: url(<?php echo $imgurl . $item['bg_wap'] ?>) no-repeat"></div>
                <div class="logo" style="background: url(<?php echo $imgurl . $item['logo'] ?>) no-repeat"></div>
                <?php if ($item['starting'] == "1"): ?>
                    <a href="<?php echo $baseurl; ?>chuong-trinh/<?php echo $item['name_ascii']; ?>.html" class="join"><span></span>Tương tác ngay</a>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>

<style type="text/css">
    #content .inner ul li .item a .schedule p{
        display: block;
        width: 100%;
        height: 100%;
        line-height: 50px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #content .inner ul li .item a:hover .schedule span{
        display: inline-block;
    }
    #content .inner ul li .item a:hover{
        white-space: nowrap;
        overflow: hidden;
        text-overflow: inherit;
    }
</style>

<script type="text/javascript">
    $('#content .inner ul li .item a').hover(function () {
        var frame = $(this).find('.schedule').width();
        var string = $(this).find('span').outerWidth();

        //console.log('span width: ' + string);

        if (string > frame) {
            $(this).find('span').addClass('marquee');
        }
    }, function () {
        if ($(this).find('span').hasClass('marquee')) {
            $(this).find('span').removeClass('marquee');
        }
    });
</script>
<script type="text/javascript">
    $(function () {
        /*
         *@Load tvshow is running 
         */
        $.get(App.Base_Api + "tv-show-is-run", function (data) {
            App.getSession("TvshowRunning",
                    function (value) {
                    },
                    function (a, b) {
                        App.setSession("TvshowRunning", "1", function () {
                            if (data.starting == 1) {
                                Toast.show({
                                    text: "Chuyển hướng tới trình đang phát..."
                                });
                                setTimeout(function () {
                                    window.location.href = App.Base_Url + "chuong-trinh/" + data.name_ascii + ".html";
                                }, 2500);
                            }
                        });
                    });

        });

        IsMobile(function (value) {
            if (value) {
                WapSlider = $('#sm-slideshow').bxSlider({
                    pager: false,
                    infiniteLoop: false,
                    adaptiveHeight: true
                });

            } else {

            }
        });
    });
</script>